import { ScrollView, View } from "@tarojs/components"

interface ISwiperProps {
    list: Array<any>
    SwiperItem: any
    onSwiperItemClick: (id: number, ...rest: any[]) => void
    swiperProps?: any
}


export const TSwiper = (props: ISwiperProps) => {
    const { list, SwiperItem, onSwiperItemClick, swiperProps } = props
    return (
        <View className="pt-[8px] pb-[8px]">
            <ScrollView className="whitespace-nowrap" scrollX={true} scrollAnchoring showScrollbar={false} enableFlex={false} >
                <View className="inline-flex w-auto">
                    {
                        list && list.map(item => {
                            return (
                                <View className='mr-[20px]' key={item.id} >
                                    <SwiperItem  {...item} item={item} {...swiperProps} onClickMethod={(id, ...rest) => { onSwiperItemClick(id, ...rest) }} />
                                </View>
                            )
                        })
                    }
                </View>
            </ScrollView>
        </View>
    )
}